1 /*
2 * Title: S/MIME Project
3 * Description: S/MIME email sending capabilities
4 * @Author Vladimir Radisic
5 * @Version 2.0.1
6 */
7
8
9 package org.webdocwf.util.smime.cms;
10
11
12 import org.webdocwf.util.smime.exception.SMIMEException;
13 import org.webdocwf.util.smime.der.DERSequencePr;
14
15
16 /***
17 * ContentInfo class is DER encoded content info represented in ASN.1 notation
18 * according to RFC2630. This class is top level class in construction of CMS
19 * objects (signed or encrypted)<BR>
20 * <BR>
21 * <DL>
22 * ContentInfo ::= SEQUENCE {<BR>
23 * <DD> contentType ContentType,<BR>
24 * <DD> content [0] EXPLICIT ANY DEFINED BY contentType }<BR>
25 * </DL>
26 * <BR>
27 * ContentType ::= OBJECT IDENTIFIER<BR>
28 * <BR>
29 * content [0]<BR>
30 */
31 public class ContentInfo extends DERSequencePr {
32
33 /***
34 * Determinate order of adding commponents
35 */
36 int orderIdentifier = 0;
37
38 /***
39 * Constructs empty Content Info. Both methods addContentType and
40 * addContent must be performed after construction, for obtaining valid CMS
41 * object.
42 * @exception SMIMEException thrown from super class.
43 */
44 public ContentInfo() throws SMIMEException {}
45
46 /***
47 * Adds Content Type to Content Info
48 * @param type0 Content Type represented as byte array
49 * @exception SMIMEException if order of adding components is wrong. Also, it
50 * can be thrown from super class addContent method.
51 */
52 public void addContentType(byte[] type0) throws SMIMEException {
53 if (orderIdentifier == 0) {
54 super.addContent(type0);
55 orderIdentifier++;
56 } else
57 throw new SMIMEException(this, 1018);
58 }
59
60 /***
61 * Adds content to Content Info
62 * @param cont0 Content represented as byte array
63 * @exception SMIMEException if order of adding components is wrong. Also, it
64 * can be thrown from super class addContent method.
65 */
66 public void addContent(byte[] cont0) throws SMIMEException {
67 if (orderIdentifier == 1) {
68 super.addContent(cont0);
69 orderIdentifier++;
70 } else
71 throw new SMIMEException(this, 1018);
72 }
73 }
74
This page was automatically generated by Maven